import 'package:flutter/cupertino.dart';
import 'package:fixnum/fixnum.dart' as $fixnum;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:get/get.dart';

import '../../../../../../lib_baseview/widget/empty_view/jr_empty_view.dart';
import '../model/room_rank_date_controller.dart';

class RoomRankDatePage extends StatelessWidget {
  final $fixnum.Int64 channelId;
  final String scope;

  RoomRankDatePage({super.key, required this.channelId, required this.scope}) {
    Get.put(RoomRankDateController(channelId, scope),
        tag: RoomRankDateController.getTag(channelId, scope));
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<RoomRankDateController>(
        tag: RoomRankDateController.getTag(channelId, scope),
        builder: (logic) {
          if (logic.errorMsg != null) {
            return JREmptyView(
              errorType: ErrorType.noData,
              desc: logic.errorMsg,
              // onTap: () => logic.loadData(state: LoadState.init),
            );
          }

          // if (logic.data == null) {
          //   return const Center(child: CupertinoActivityIndicator());
          // }

          // if (logic.data!.isEmpty) {
          //   return JREmptyView(
          //       errorType: ErrorType.noData,
          //       desc: T.current!.no_data_click_refresh,
          //       onTap: () => logic.loadData(state: LoadState.init));
          // }

          return Container(
            child: Stack(
              children: [
                RefreshIndicator(
                  onRefresh: () async {
                    // await logic.loadData(state: LoadState.refresh);
                  },
                  child: NotificationListener(
                    onNotification: (notification) {
                      if (notification is UserScrollNotification) {
                        if (notification.direction == ScrollDirection.idle) {
                          if (notification.metrics.extentAfter <= 0 &&
                              logic.hasMore) {
                            // logic.loadData(state: LoadState.loadMore);
                          }
                        }
                      }
                      return false;
                    },
                    child: Text('ListView.builder'),
                    // child: ListView.builder(
                    //   physics: const AlwaysScrollableScrollPhysics(
                    //       parent: BouncingScrollPhysics()),
                    //   itemBuilder: (c, index) {
                    //     bool isLast = index == logic.len - 1;
                    //     if (logic.hasMore && isLast) {
                    //       return Padding(
                    //         padding: EdgeInsets.only(
                    //             top: 0.0,
                    //             bottom: 80.h + ScreenUtils.ins.iphoneXBottom),
                    //         child: Center(
                    //             child: Row(
                    //           mainAxisSize: MainAxisSize.min,
                    //           children: [
                    //             SizedBox(
                    //               width: 16.w,
                    //               height: 16.h,
                    //               child: CircularProgressIndicator(
                    //                   backgroundColor: AppColors.lightGreyBg
                    //                       .withOpacity(0.5),
                    //                   valueColor:
                    //                       const AlwaysStoppedAnimation<Color>(
                    //                           Color(0xFFBBBBBB)), // 进度条当前进度颜色,
                    //                   strokeWidth: 2),
                    //             ),
                    //             SizedBox(width: 8.w),
                    //             Text(T.current!.load_more,
                    //                 style: JRTextStyles.styleFont12W400
                    //                     .copyWith(color: AppColors.secondText))
                    //           ],
                    //         )),
                    //       );
                    //     }
                    //     return Padding(
                    //       padding: EdgeInsets.only(bottom: isLast ? 100.h : 0),
                    //       child: RoomRankItemWidget(
                    //         item: logic.data![index],
                    //         index: index,
                    //         inRoom: true,
                    //       ),
                    //     );
                    //   },
                    //   itemCount: logic.data!.length,
                    // ),
                  ),
                ),
                PositionedDirectional(
                  bottom: 0,
                  start: 0,
                  end: 0,
                  child: Container(
                    decoration: BoxDecoration(color: Colors.white, boxShadow: [
                      BoxShadow(
                          color: Colors.black.withOpacity(0.06),
                          offset: const Offset(0, -4),
                          blurRadius: 12)
                    ]),
                    child: Text('RoomRankItemWidget'),
                    // child: SafeArea(
                    //   child: RoomRankItemWidget(
                    //     item: logic.mySelf!,
                    //     index: logic.mySelf!.rank - 1,
                    //     nearbyUser: logic.nearbyMeUser,
                    //   ),
                    // ),
                  ),
                )
              ],
            ),
          );
        });
  }
}
